#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int a[100001], c[100001],ra[100001];
int l[20][70000],A[4],num[100001],b;
string s;
int t,m,n,ans;
int f(int x){
    int a=1,k=0;
    while(a>=x)
        a*=2,k++;
return k;
}
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=m;i++)
        cin>>c[i];
    for(int i=1;i<=f(n);i++){
        cin>>s;
cin>>t;
for(int k=1;k<= t;k++){
    cin>>A[0]>>A[1]>>A[2]>>A[3];
    for(int i=1;i<=c[k];i++)
        ra[i]=a[i]^A[i%4];
        for(int i=1;i<=m;i++)
            ans^=(ra[1]*i);
}
return 0;
}}
